<template>
    <div class="team">
        <div class="lv2-team">
            <div class="lv2" v-for="(item,index) in level2" :key="index" @click="toLv3(item.distributor.id)">
                <div class="left">
                    <div class="avatar-box">
                        <img :src="item.distributor.image_url" alt="">
                    </div>
                    <div class="left-msg">
                        <div class="top">
                            <img src="~assets/icons/vip2.png" alt="">
                            <span>{{item.distributor.nickname}}</span>
                        </div>
                        <div class="bottom">
                            <span>ID: {{item.distributor.id}}</span>
                        </div>
                    </div>
                </div>
                <div class="right">
                    <span>共{{item.number}}人</span>
                    <img src="~assets/icons/partners.png" alt="">
                    <img src="~assets/icons/arrow.png" alt="">
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name:'team',
    data(){
        return {
            level2:[]
        }
    },
    methods:{
        toLv3(id){
            this.$router.push({path:'/distribution/team_lv3', query:{lv2Id:id}});
        },
        getLv2Team(){
            let that = this;
            let token = localStorage.getItem('token');
            let disNum = localStorage.getItem('distribution');
            let loader = that.loading();
            that.$ajax(that, 'get', that.$api.teamLv2+disNum, null, token, function(res){
                if(res.data['error_code'] == 0){
                    that.level2 = res.data['msg'];
                }else{
                    that.toast(res.data['msg']);
                }
                loader.close();
            })
        }
    },
    mounted(){
        this.$store.state.tab = '二级分销团队';
        this.getLv2Team();
    },
    activated(){
        this.$store.state.tab = '二级分销团队';
        this.getLv2Team();
    }
}
</script>

<style lang='less'>
@rem:100rem;

.team{
    width: 750/@rem;
    margin-top: 88/@rem;
    .team-head{
        width: 100%;
        height: 100/@rem;
        display: flex;
        border-bottom: 1px solid #e5e5e5;
        border-top: 1px solid #e5e5e5;
        background: #ffffff;
        .level{
            width: 50%;
            height: 100%;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: center;
            img{
                width: 30/@rem;
                height: 30/@rem;
            }
            span{
                font-size: 30/@rem;
                color: #444444;
                margin-left: 20/@rem;
            }
        }
        .level:nth-of-type(1){
            border-right: 1px solid #e5e5e5;
        }
    }
    .lv2-team{
        width: 100%;
        background: #ffffff;
        margin-top: 20/@rem;
        .lv2{
            display: flex;
            width: 100%;
            height: 90/@rem;
            align-items: center;
            justify-content: space-between;
            border-top: 1px solid #e5e5e5;
            .left{
                display: flex;
                height: 100%;
                align-items: center;
                margin-left: 40/@rem;
                .avatar-box{
                    width: 60/@rem;
                    height: 60/@rem;
                    border-radius: 6/@rem;
                    overflow: hidden;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    img{
                        width: 60/@rem;
                        height: 60/@rem;
                        border-radius: 6/@rem;
                    }
                }
                .left-msg{
                    text-align: start;
                    margin-left: 10/@rem;
                    .top{
                        img{
                            width: 30/@rem;
                            height: 30/@rem;
                        }
                        span{
                            font-size: 30/@rem;
                            color: #444444;
                            margin-left: 16/@rem;
                        }
                    }
                    .bottom{
                        font-size: 24/@rem;
                        color: #999999;
                    }
                }
            }
            .right{
                height: 100%;
                display: flex;
                align-items: center;
                margin-right: 30/@rem;
                span{
                    font-size: 24/@rem;
                    color: #999999;
                    margin-right: 12/@rem;
                }
                img:nth-of-type(1){
                    width: 44/@rem;
                    height: 34/@rem;
                    margin-right: 16/@rem;
                }
                img:nth-of-type(2){
                    width: 36/@rem;
                    height: 36/@rem;
                }
            }
        }
    }
    .lv3-team{
        width: 100%;
        background: #ffffff;
        margin-top: 20/@rem;
        .level-detail{
            display: flex;
            height: 90/@rem;
            width: 100%;
            align-items: center;
            border-top: 1px solid #e5e5e5;
            .avatar-box{
                width: 60/@rem;
                height: 60/@rem;
                border-radius: 6/@rem;
                overflow: hidden;
                display: flex;
                align-items: center;
                justify-content: center;
                margin-left: 40/@rem;
                img{
                    width: 60/@rem;
                    height: 60/@rem;
                    border-radius: 6/@rem;
                }
            }
            .left-msg{
                text-align: start;
                margin-left: 10/@rem;
                .top{
                    img{
                        width: 30/@rem;
                        height: 30/@rem;
                    }
                    span{
                        font-size: 30/@rem;
                        color: #444444;
                        margin-left: 16/@rem;
                    }
                }
                .bottom{
                    font-size: 24/@rem;
                    color: #999999;
                }
            }
        }
    }
}
</style>
